package com.cgtong.android.mvp.model;

import com.cgtong.android.bean.MonthYearReportBean;
import com.cgtong.android.http.ApiManager;
import com.cgtong.android.http.callback.BaseCallBack;
import com.cgtong.android.mvp.contract.MonthReportContract;
import com.zhouyou.http.EasyHttp;
import com.zhouyou.http.callback.CallBackProxy;
import com.zhouyou.http.callback.SimpleCallBack;
import com.zhouyou.http.exception.ApiException;
import com.zhouyou.http.model.ApiResult;

import java.util.List;

/**
 * Created by chunc on 2017/10/31.
 */

public class MonthReportModel implements MonthReportContract.Model {
    @Override
    public void httpMonthReportData(String beginMonth, final BaseCallBack<List<MonthYearReportBean>> baseCallBack) {
        EasyHttp.post(ApiManager.PROBLEM_MONTH_REPORT_URL)
                .params("beginmon", beginMonth)
                .accessToken(true)//本次请求是否追加token
                .execute(new CallBackProxy<ApiResult<List<MonthYearReportBean>>, List<MonthYearReportBean>>(new SimpleCallBack<List<MonthYearReportBean>>() {
                    @Override
                    public void onError(ApiException e) {
                        baseCallBack.onError(e);
                    }

                    @Override
                    public void onSuccess(List<MonthYearReportBean> problemBeen) {
                        baseCallBack.onSuccess(problemBeen);
                    }
                }) {
                });
    }
}
